//
//  FZVisitorViewController.swift
//  FZSina_Swift
//
//  Created by 李忠 on 7/19/16.
//  Copyright © 2016 FZLZ. All rights reserved.
//

import UIKit
import JPFPSStatus
let padding: CGFloat = 10

class FZVisitorViewController: UIViewController {
    //MARK: 记录师傅登陆
//    let isLogin: Bool = false
    let isLogin = FZUserAccountViewModel.sharedUserAcount.isLogin
    //MARK: 重写loadView方法，用于判断登陆哪一种页面
    override func loadView() {
        self.view = isLogin ? tableView : noLoginView
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        JPFPSStatus.sharedInstance().open()
    }
    
//MARK:==========================事件==========================
    func clickLoginButton()  {
        
        let vc: FZOAuthViewController = FZOAuthViewController()
        
        
        presentViewController(UINavigationController(rootViewController: vc), animated: true, completion: nil)
        
    }
    func clickResginButton() {
        clickLoginButton()
    }
//MARK:==========================懒加载==========================
    //MARK: 懒加载
     lazy var tableView: UITableView = {
        
        let tableView: UITableView = UITableView(frame:UIScreen.mainScreen().bounds)
        tableView.tableFooterView = UIView()
        
        tableView.backgroundColor = TheTableColor
        
        return tableView;
    }()
    lazy var noLoginView: FZVisitorView = {
        let visirtorView: FZVisitorView = FZVisitorView(frame:UIScreen.mainScreen().bounds)
        
        //MARK: 闭包赋值
        visirtorView.clickResginClosure = {
            [weak self] in
            self?.clickLoginButton()
        }
        visirtorView.clickLoginClosure = {
            [weak self] in
            self?.clickLoginButton()
        }

        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", target: self, action: #selector(clickLoginButton))
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: #selector(clickResginButton))
        
        return visirtorView;
    }()
}
